﻿@namespace Blazorise
@inherits BaseComponent
@{
    var tooltip = Rating?.GetTooltip?.Invoke( Value );
}

@if ( string.IsNullOrEmpty( tooltip?.Text ) )
{
    @RatingItemTemplate
}
else
{
    <Tooltip Text="@tooltip.Text" Placement="@tooltip.Placement" Multiline="@tooltip.Multiline" ShowArrow="@tooltip.ShowArrow" Inline>
        @RatingItemTemplate
    </Tooltip>
}
@code {
    private RenderFragment RatingItemTemplate => __builder =>
    {
        @if ( Rating.ReadOnly )
        {
            <span @ref="@ElementRef" id="@ElementId" class="@ClassNames" style="@StyleNames">
                <Icon Name="@IconName" IconStyle="@IconStyle" />
            </span>
        }
        else
        {
            <span @ref="@ElementRef" id="@ElementId" class="@ClassNames" style="@StyleNames" @onclick="@HandleClick" @onmouseover="@HandleMouseOver" @onmouseout="@HandleMouseOut">
                <Icon Name="@IconName" IconStyle="@IconStyle" />
            </span>
        }
    };
}